// @Description
// @Author  xiaoyang
// @Date  2023/4/28 3:52 下午

package dao

import (
	"github.com/jinzhu/gorm"
	"golang-manage-admin/providers"
)

const (
	HandleResultNo      = 0 // 执行结果：未执行
	HandleResultSuccess = 1 // 执行结果：执行成功
	HandleResultFail    = 2 // 执行结果：执行成功

	DealWithTypeQueue = 1 // 执行方式：延时队列
)

type DelayedQueueDao struct {
	BaseDao
}

func NewDelayedQueueDao() *DelayedQueueDao {
	dao := new(DelayedQueueDao)
	dao.init()
	return dao
}

// UpdateDelayedQueueInfo
/**
 *  @Author yang
 *  @Description 更新任务信息
**/
func (dqd *DelayedQueueDao) UpdateDelayedQueueInfo(tx *gorm.DB, delayedQueue DelayedQueueTable) (DelayedQueueTable, error) {
	// 事务
	tx = dqd.checkStartTransaction(tx, providers.Mysql)
	err := tx.Model(&delayedQueue).Where("task_id = ?", delayedQueue.TaskId).Update(delayedQueue).Error
	if err != nil {
		return delayedQueue, err
	}
	return delayedQueue, nil
}
